<%--
  Created by IntelliJ IDEA.
  User: 10475
  Date: 2023/2/23
  Time: 11:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加企业</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css" media="all">
    <script src="${pageContext.request.contextPath}/lib/layui-v2.6.3/layui.js"></script>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<h2>添加学生</h2>

<%--lay-filter="useradmin" id="useradmin"--%>
<form class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">用户账号：</label>
        <div class="layui-input-inline">
            <input type="text" id="userId" name="userId" lay-verify="required" value="${user.userId}" autocomplete="off" class="layui-input" readonly="readonly">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">职位号：</label>
        <div class="layui-input-inline">
            <input type="text" id="jobId" name="jobId" lay-verify="required" value="${user.userId}" autocomplete="off" class="layui-input" readonly="readonly">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">真实姓名：</label>
        <div class="layui-input-inline">
            <input type="text" id="realName" name="realName"  value="${user.realName}" lay-verify="required" readonly="readonly" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">性别：</label>
            <div class="layui-input-inline">
            <input type="text" id="uSex" name="uSex"  value="${user.uSex}" lay-verify="required" readonly="readonly" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">年 龄:</label>
        <div class="layui-input-inline">
            <input type="text" id="age" name="age"  value="${user.age}"  lay-verify="required" readonly="readonly" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">毕业院校:</label>
        <div class="layui-input-inline">
            <input type="text" id="school" name="school"  value="${user.school}" readonly="readonly" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">学历:</label>
        <div class="layui-input-inline">
            <input type="text" id="xueLi" name="xueLi"  value="${user.xueLi}" readonly="readonly" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">专业:</label>
        <div class="layui-input-inline">
            <input type="text" id="major" name="major"  value="${user.major}" readonly="readonly" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">身份证号:</label>
        <div class="layui-input-inline">
            <input type="text" id="cardNum" name="cardNum"  value="${user.cardNum}" readonly="readonly" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">电&nbsp;话:</label>
        <div class="layui-input-inline">
            <input type="text" id="companyTel"  value="${user.tel}" readonly="readonly" name="companyTel" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">简历以及相关文档:</label>
        <div class="layui-input-inline">
            <div class="layui-upload">
                <button type="button" class="layui-btn layui-btn-normal" id="testList">选择压缩文件</button>
                <div class="layui-upload-list" style="max-width: 1000px;">
                    <table class="layui-table">
                        <colgroup>
                            <col>
                            <col width="150">
                            <col width="260">
                            <col width="150">
                        </colgroup>
                        <thead>
                        <tr><th>文件名</th>
                            <th>大小</th>
                            <th>上传进度</th>
                            <th>操作</th>
                        </tr></thead>
                        <tbody id="demoList"></tbody>
                    </table>
                </div>

            </div>
        </div>
    </div>

        <div class="layui-form-item">
            <label class="layui-form-label">***个人描述：</label>
            <div class="layui-input-inline">
                <textarea placeholder="请输入内容"  value="${user.description}" class="description" id="description" readonly="readonly">${user.description}</textarea>
            </div>
        </div>

    <button type="button" class="layui-btn" id="testListAction">投递简历</button>

</form>
</body>
<script type="text/javascript">
    function submitCompany() {

        var userId=$("#userId").val();
        var realName=$("#realName").val();
        var uSex=$("#uSex").val();
        var school=$("#school").val();
        var xueLi=$("#xueLi").val();
        var name=$("#name").val();
        var major=$("#major").val();
        var cardNum=$("#cardNum").val();
        var tel=$("#tel").val();
        var description=$("#description").val();
        var age=$("#age").val();

        console.log(state);
        if(userId.length==0||realName.length==0||uSex.length==0||school.length==0||
            xueLi.length==0||name.length==0||major.length==0||cardNum.length==0||
            tel.length==0||description.length==0||age.length==0){
            layer.msg('请重新完善简历',{icon: 5});
        } else{

            layer.msg('完善了简历',{icon: 5});
        }
    }
</script>
<script>
    layui.use('form', function(){
        var form = layui.form;

    });
</script>
<script>
    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;
//演示文件上传
        var demoListView = $('#demoList')
            ,uploadListIns = upload.render({
            elem: '#testList'
            ,url: '${pageContext.request.contextPath}/UploadServlet' //此处用的是第三方的 http 请求演示，实际使用时改成您自己的上传接口即可。
            ,accept: 'file'
            ,number:1
            ,multiple: false
            ,exts: 'zip|rar|7z' //只允许上传压缩文件
            ,auto: false
            ,bindAction: '#testListAction'
            ,choose: function(obj){
                var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                //读取本地文件
                obj.preview(function(index, file, result){
                    var tr = $(['<tr id="upload-'+ index +'">'
                        ,'<td>'+ file.name +'</td>'
                        ,'<td>'+ (file.size/1014).toFixed(1) +'kb</td>'
                        ,'<td>等待上传</td>'
                        ,'<td>'
                        ,'<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>'
                        ,'<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
                        ,'</td>'
                        ,'</tr>'].join(''));

                    //单个重传
                    tr.find('.demo-reload').on('click', function(){
                        obj.upload(index, file);
                    });

                    //删除
                    tr.find('.demo-delete').on('click', function(){
                        delete files[index]; //删除对应的文件
                        tr.remove();
                        uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                    });

                    demoListView.append(tr);
                });
            }
            ,done: function(res, index, upload){
                console.log(res);
                console.log(index);
                console.log(upload);
                var jobId=$('#jobId').val();
                var userId=$('#userId').val();
                var description=$('#description').val();
                p=res.src2;
                var realName=$("#realName").val();
                var uSex=$("#uSex").val();
                var school=$("#school").val();
                var xueLi=$("#xueLi").val();
                var name=$("#name").val();
                var major=$("#major").val();
                var cardNum=$("#cardNum").val();
                var tel=$("#tel").val();
                var age=$("#age").val();


                //成功的回调
                if(res){ //上传成功
                    p=res.src2;
                    $.ajax({
                        type:"get",
                        url:"${pageContext.request.contextPath}/AddResume?jobId="+jobId+"&userId="+userId+"&src="+p+"&description="+description,
                        dataType:"text",
                        success:function(res) {
                            if(res=="success") {
                                layer.msg("投递成功");
                            }else {
                                layer.msg("投递失败");
                            }
                        }
                    })
                    var tr = demoListView.find('tr#upload-'+ index)
                        ,tds = tr.children();
                    tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
                    tds.eq(3).html(''); //清空操作
                    return  delete this.files[index]; //删除文件队列已经上传成功的文件
                }
                this.error(index, upload);
            }
            ,error: function(index, upload){ //错误回调
                var tr = demoListView.find('tr#upload-'+ index)
                    ,tds = tr.children();
                tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
                tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
            }
        });
    }) //如果少了该"})"",那么逻辑 会出错，点击文件上传会没有反应
</script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#addTime'
        });
    });
</script>
</html>
